﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
    <title></title>
    <link href="../CSS/style1.css" rel="stylesheet" type="text/css" />
    <link href="../CSS/style4.css" rel="stylesheet" type="text/css" />
    <script src="../Scripts/jquery-1.4.1-vsdoc.js" type="text/javascript"></script>
    <script src="../Scripts/jquery.showModalDialog.js" type="text/javascript"></script>
    <script type="text/javascript">
        //得到学员的ID
        var id = window.dialogArguments.id;
        
        $(function () {
            Load();
            List();
        });
        function Load() {
            
            //通过id将资料从数据库中查询出来
            $.ajax({
                url: "roleManager.asmx/FindRole",
                type: "post",
                data: JSON.stringify({ id: parseInt(id) }),
                dataType: "json",
                contentType: "application/json",
                success: function (obj) {
                    
                    $("#select1").append('<option value="' + obj.d.RoleName + '">' + obj.d.RoleName + '</option>');
                    
                }, error: function (xmlhttp) {
                    alert("错误：" + xmlhttp.responseText);
                }
            });
        }
        function List() {
            $.ajax({
                url: "roleManager.asmx/SelectRole",
                type: "post",
                data: JSON.stringify({}),
                dataType: "json",
                contentType: "application/json",
                success: function (obj) {
                    var sel1 = $("#select1");
                    for (var i = 0; i < obj.d.length; i++) {
                        sel1.append('<option value="' + obj.d[i].RoleName + '">' + obj.d[i].RoleName + '</option>');
                    }
                }, error: function (xmlhttp) {
                    alert("错误：" + xmlhttp.responseText);
                }
            });
        }
        //修改成功销售机会
        function ok() {
            var r = {
                roleName: $("#select1").val(),
                ID:id
            };
            //发起更新请求
            $.ajax({
                url: "roleManager.asmx/UpdateRole",
                type: "post",
                data: JSON.stringify({ r:r}),
                dataType: "json",
                contentType: "application/json",
                success: function (obj) {
                    alert(obj.d ? "您已修改成功" : "您修改失败，请稍候再试");
                    //刷新
                    window.returnValue = true;
                    window.close();
                }, error: function (xmlhttp) {
                    alert("错误：" + xmlhttp.responseText);
                }
            });
        };

    </script>
</head>
<body>
    <table class="tableEdit">
        <thead>
            <tr>
                <td>扮演角色修改</td>
            </tr>
        </thead>
        <tr>
            <th>角色名称：</th>
            <td>
                <select id="select1" style="color:blue;">
                    
                </select>
           </td>
        </tr>
        <tfoot>
            <tr>
                <td colspan="4" style="text-align:center">
                    <input type="button" value="确定" onclick="ok();" />&nbsp;&nbsp;
                    <input type="button" value="关闭" onclick="window.close()" />
                </td>
            </tr>
        </tfoot>
    </table>
</body>
</html>
